package com.bailu.zsb_back.controller;

import com.bailu.zsb_back.service.BookService;
import com.bailu.zsb_back.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author dell
 */
@CrossOrigin(origins = "http://localhost:5500")
@RestController
public class BookController {
    @Autowired
    private BookService bookService;
    @GetMapping("/books")
    public R getBooks(@RequestParam(required = false,defaultValue = "1") int page,
                      @RequestParam(required = false,defaultValue = "2") int limit,
                      @RequestParam(required = false,defaultValue = "") String name) {

        return R.ok(bookService.findAllBooks(page,limit,name));
    }
}
